/**
 * 字符串去空格
 * @returns 去除空格后的字符串
 */
String.prototype.trim = function(){
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
};

/**
 * 显示提示信息内容
 * @param tdObj 内容显示的TD列
 * @param spanObj 内容显示的Span对象
 * @param infoMsg 要显示的信息
 */
function displayInfoStyle(tdObj, spanObj, infoMsg) {
    if(tdObj) {
        tdObj.className = "labbg_normal";
    }
    if(spanObj) {
        spanObj.style.display = "block";
        spanObj.innerHTML = infoMsg;
    }
}

/**
 * 显示错误提示信息内容
 * @param tdObj 内容显示的TD列
 * @param spanObj 内容显示的Span对象
 * @param infoMsg 要显示的信息
 */
function displayErrorStyle(tdObj, spanObj, infoMsg) {
    if(tdObj) {
        tdObj.className = "labbg_err";
    }
    if(spanObj) {
        spanObj.style.display = "block";
        spanObj.innerHTML = infoMsg;
    }
}

/**
 * 校验通过时调用
 * @param tdObj 信息显示列
 * @param spanObj 信息显示Span
 */
function displayOkStyle(tdObj, spanObj) {
	if(tdObj) {
        tdObj.className = "";
    }
    if(spanObj) {
        spanObj.style.display = "none";
        spanObj.innerHTML = "";
    }
}

/**
 * 界面上操作给出提示
 */
function operConfirm(url, recordInfo) {
	var rs =window.confirm("您确定要删除记录" + recordInfo + "吗？");
	if(rs) {
		window.location.href=url;
		return true;
	}
	return false;
}

/**
 * 界面上操作给出提示. 通过Form表单提交
 * @param formId
 * @returns {Boolean}
 */
function operConfirmByForm(formId) {
	var rs =window.confirm("您确定要删除所选记录吗？");
	if(rs) {
		document.getElementById(formId).submit();
		return true;
	}
	return false;
}

/**
 * 全选CheckBox点击事件，如果选中则使当前页的CheckBox全选中；如果取消选中则使当前页的CheckBox全取消
 * @param ckObj
 * @param cksName
 */
function batchSelectAll(ckObj, cksName) {
	var cks = document.getElementsByName(cksName);
	var cksLen = cks.length;
	if(ckObj.checked) {
		// 全选
		for(var i = 0; i < cksLen; i++) {
			cks[i].checked = true;
		}
	} else {
		// 全不选
		for(var i = 0; i < cksLen; i++) {
			cks[i].checked = false;
		}
	}
}

/**
 * 表单项获取焦点时进行的处理
 * @param td_id_Col 提示信息显示TD列的ID
 * @param s_id_Desc 提示信息显示区域的ID
 * @param infoMsg 提示信息内容
 */
function focusChk(td_id_Col, s_id_Desc, infoMsg) {
	var td_id_ColObj = document.getElementById(td_id_Col);
    var s_id_DescObj = document.getElementById(s_id_Desc);
    displayInfoStyle(td_id_ColObj, s_id_DescObj, infoMsg);
}

/**
 * 
 * @param td_id_Col
 * @param s_id_Desc
 * @param errMsg
 * @returns {Boolean}
 */
function blurChk(td_id_Col, s_id_Desc, errMsg) {
	var chkResult = true;
	
    var td_id_ColObj = document.getElementById(td_id_Col);
    var s_id_DescObj = document.getElementById(s_id_Desc);
    
    if(errMsg != "") {
        displayErrorStyle(td_id_ColObj, s_id_DescObj, errMsg);
        chkResult = false;
        return chkResult;
    }
    
    // 校验通过
    displayOkStyle(td_id_ColObj, s_id_DescObj);
    return chkResult;
}